using HKB.Common;
using System;
using System.Data;
namespace HKB.Web.Shop
{
	public class HoWaveProduct
	{
		private Conn conn = null;
		private Pagination _pageHand = null;
		public virtual Pagination pageHand
		{
			get
			{
				Pagination pageHand;
				if (this._pageHand == null)
				{
					this._pageHand = new Pagination();
					this._pageHand.SQL_CloseTablePre = false;
					this._pageHand.SQL_Fields = "*,CurrentPrice as Price,DateDiff(ss,getdate(),EndDate) as LeftTime,(Select UserName From [HL_User] Where HL_User.UserID=HLShop_Product.SalerID) as SalerName";
					this._pageHand.P_Object = Language.GetAdminMsg("Product/ProductName");
					pageHand = this._pageHand;
				}
				else
				{
					pageHand = this._pageHand;
				}
				return pageHand;
			}
		}
		public HoWaveProduct(Conn _conn)
		{
			this.conn = _conn;
		}
		public virtual DataTable ProductList(int indexpage, int maxperpage, string WhereStr, string OrderByStr, params IDbDataParameter[] param)
		{
			DataTable dataTable;
			if (param == null)
			{
				dataTable = this.pageHand.GetDataTable("HLShop_Product", indexpage, maxperpage, "ProductID", WhereStr, OrderByStr, this.conn, null);
			}
			else
			{
				dataTable = this.pageHand.GetDataTable("HLShop_Product", indexpage, maxperpage, "ProductID", WhereStr, OrderByStr, this.conn, param);
			}
			return dataTable;
		}
		public virtual DataTable GetProductByID(int id)
		{
			return this.pageHand.GetDataTable("HLShop_Product", 1, 1, "ProductID", "Where ProductID=" + id, "", this.conn, null);
		}
		public string GetPagePanel(string LinkHead)
		{
			this._pageHand.P_LinkHead = LinkHead;
			return this._pageHand.ShowPagePanel();
		}
		public DataSet GetGroupProduct(int id)
		{
			return this.conn.GetDataSet("select top 3 a.SalerID as SID, * from HL_GroupShopProduct as a,HLShop_Product as b where a.MainproductID=b.ProductID and a.MainproductID=" + id);
		}
	}
}
